package ntd.remote.file.action;

import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.log.StaticLog;
import ntd.action.ActionAbs;
import ntd.action.bo.ActionInfo;
import ntd.action.bo.ActionOutBo;
import ntd.remote.file.bo.ComRemoteFileBO;
import ntd.remote.link.ComRegistryClient;
import ntd.remote.link.bo.MsgBO;

public class ActionRemoteRead extends ActionAbs {

    public static final String ACTION_CODE = "action-netty-remote-file-read";

    @Override
    public ActionInfo info() {
        return new ActionInfo("netty 远程文件删除操作", ACTION_CODE, this);
    }

    @Override
    public ActionOutBo handle() {
        MsgBO msgBOIn = actionInBo.getData().toBean(MsgBO.class);
        ComRemoteFileBO comRemoteFileBO = JSONUtil.toBean(msgBOIn.getData(), ComRemoteFileBO.class);

        StaticLog.info("netty 远程文件[{}]读取操作", comRemoteFileBO.getPath());

        return new ActionOutBo(FileUtil.readBytes(comRemoteFileBO.getPath()));
    }
}
